<?php
require_once("includes/pagetop.php");
include_once("updates/CommonFeatures.php");
include_once("includes/common_snippets.php");
include_once("lib/functions.php");

getProjectRootPath();

//include_once ("../updates/PostActions.php");


if(!isset($_SESSION['Allyfolio_User_ID']) || $_SESSION['Allyfolio_User_ID']==0)
{
    redirect("index.php");
}

$noofappsloadpermoreclick=1;
$noofsponcersdefault=5;
$logObj=new Log();


//print_r($_POST["Post"]);
//echo "<br>";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>AllyFolio | Techno Path </title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all"  />

<script src="js/general.js"></script>
<script src="js/functions.js"></script>


<link rel="stylesheet" href="bin/magicsuggest-1.3.1-min.css"/>
<script type="text/javascript" src="bin/jquery-1.8.3-min.js"></script>
<script type="text/javascript" src="bin/magicsuggest-1.3.1-min.js"></script>

<link rel="stylesheet" href="alertify/themes/alertify.core.css" />
<link rel="stylesheet" href="alertify/themes/alertify.default.css" id="toggleCSS" />
<script src="alertify/lib/alertify.min.js"></script>	
<script src="js/jquery1.10.2.min.js"></script>

<script src="js/modernizr.custom.56223.js"></script>
<style type="text/css">

    .chat_box{

        display:none;

    }

    .placeholder {

      color: #cccccc;

      }
/* emotions */
#emotionsdrp{
    position: absolute;
    padding: 4px;
}

#emotionsdrp div .em{
    cursor: pointer;
    padding: 2px;
} 
#emotionsdrp{
    background-color: gainsboro;
    width: 130px;
}
.em{
    
}
.em:hover{
    background-color: cadetblue;
    cursor:pointer;
}
</style>
<style type="text/css">

	.logo{ margin-top:10px;}

	.log_button{

	

	height:auto;

	margin:6px 0;

	overflow:hidden;

	float:left;

	margin-top:10px;

	

	}

	.new tr td{ vertical-align:top}

	

	textarea select{ border:1px solid #ccc}

	input textarea select{ border:1px solid #999}

    

    /* added by sujeet */

    .privacy-drp-menu{

        border:1px solid blue;

        display: none;

    }

    .privacy-drp-menu-items{

        border-bottom: 1px solid gray;

        cursor:pointer;

    }

    .comment{

        width: 82%;

        height: 25px;

        padding-left: 4px;

        padding-right: 4px;

        border:none; 

        background:none;

    }   

    .listenMe{

        width: 100%;

        text-align: center;

        padding-top: 14px;

        padding-bottom: 14px;

    }

    .feed{

        margin-top: 20px;

    }

</style>

<!-- custom post submission jquery by sujeet -->
<?php include_once("smiley.php");?>
<script type="text/javascript" src="js/smiley.js"></script>
<script src="js/autoloading.js"></script>
<script src="js/custom_popupshow.js"></script>
<script src="js/jquery.asyncpost.js"></script>
<script type="text/javascript" src="js/jwplayer.js"></script>

<script type="text/javascript" src="js/jquery_1.9.0.min.js"> </script>
<script type="text/javascript" src="js/script.js"></script>


<script src="js/jquery.placeholder.js"></script>
<!-- For sharing popup -->
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript">
    $(function() { $('input, textarea').placeholder();});
</script>
<style type="text/css">
    .placeholder {
      color: #cccccc;
      }
</style>

</head>

<body>
<?php

if(isset($_POST["action"]) && trim($_POST["action"])=="tc_post"){
  require_once($_SERVER['DOCUMENT_ROOT']."/updates/PostActions.php");
//verify post and required fields to move to update status and posts
  include_once($_SERVER['DOCUMENT_ROOT']."/ajax/post_script_src.php");
  if($executionResult["err_code"]==200){
    
  }
}

try{
    $loggedUserObj=new UserDetails();
    
    if (!isset($_SESSION["User_details"])){
        $_SESSION["User_details"]=$loggedUserObj->getUserDetails($_SESSION["Allyfolio_User_ID"],true);
    }
    $loggedUserObj=$_SESSION["User_details"];
    $loggedUserObj->latestFriendNotificationsArr=array(1=>"sumer",2=>"vikas");            
    //echo "<pre>";
//    print_r($loggedUserObj);
//    echo "</pre>";

}
catch(Exception $ex){
    $logObj->writeException("home.php Exception: => ".$ex->getMessage());
    die("techno.php fetching user details".$ex->getMessage());
}

$currentPostCategory=0;
include_once("updates/ReadNotifications.php");
?>
	<div id="main_wrapper">
    <?php
    require_once("includes/main_header.php");
    
    
    $sponcerinfo=$pdodbobj->fetch_array($pdodbobj->query("select * from af_sponcers where sponcer_status='Active' order by rand() limit ".$noofsponcersdefault,array()));
    $technocats=$pdodbobj->fetch_array($pdodbobj->query("select id,cat_name from af_technocategories ",array()));
    ?>
    
    
    <!--=================Body Contain Start=======================-->
    
    <div class="wrapper">
      <div class="header">
        <div class="contain-wrap2 shadow" style="margin-top:30px; width:100%; ">
		   <div style="color:#000; font-size:32px; text-align:center; padding-bottom:30px;" class="creat_txt">
            	Techno Path
            </div>
          <form name="technoform" method="post">
            <div class="home_left">
    		
        		<table width="100%">
    				<tr>
    					<td>
    						<table border="0"><tr><td>
                                <img src="images/srch.png" onclick="return searchContent('<?php echo $loggedUserObj->userId; ?>','<?php echo $loggedUserObj->privacyType["Default_Setting"]; ?>',true,postTypeToRead.techno,'-1',$('#technoSearch').val(),true);" style="cursor: pointer;"/></td><td><input id="technoSearch" type="text" class="serch_blue" placeholder="Search here" /></td></tr></table>
    					
    					</td>
    					
    				</tr>
    				
                </table>
    			<table width="100%" style="border-right:1px solid #999">
                    <tr>
        				<td>
        					<ul class="font14" style="color:#7b7f81; font-weight:bold;">
                            <li><a href="javascript:void(0);" onclick="window.location='techno.php';" >All</a></li>
                            <li><a href="javascript:OnViewMore('<?php echo $loggedUserObj->userId; ?>','<?php echo $loggedUserObj->privacyType["Default_Setting"]; ?>',true,postTypeToRead.techno,'-2');" >Trends</a></li>
                            </ul>
                            <br />
                            <ul class="font14" style="color:#7b7f81; font-weight:bold;">
                            <?php
                            for($i=0;$i<count($technocats);$i++)
                            {
                                ?>
                                <li><a href="javascript:OnViewMore('<?php echo $loggedUserObj->userId; ?>','<?php echo $loggedUserObj->privacyType["Default_Setting"]; ?>',true,postTypeToRead.techno,'<?php echo $technocats[$i]['id']; ?>');" ><?php echo $technocats[$i]['cat_name']; ?></a></li>
                                <?php
                            }
                            ?>
                            </ul>
                            <br/>
                            <ul class="font14" style="color:#7b7f81; font-weight:bold;">
        						<li><a href="#">Followers</a></li>
        						<li><a href="#">Following</a></li>
        					</ul>
        				</td>
                    </tr>
                    
                    <tr>
        				<td style="padding-top:87px;color:#7B7F81">
        					Users can upload
                            their Technologies,
                            gadgets & Research
                            					
        				</td>
        			</tr>
        			<tr>
        				<td align="center">
        					<input type="button" class="upload3 button small pop1" data-bpopup='{"transition":"slideDown","speed":850,"easing":"easeOutBack"}'  />
                            
        				</td>
        			</tr>
        		</table>
    		</div>
            </form>
		<div class="home_right" style="width:660px">
	
		
        <style>
        #tweets { }
        #overlay { position: absolute; left: 168px; top: 87px;
           width: 408px; height:386px; background: url("../images/transpBlue_overlay.png"); }
        #overlay img { position:relative; left:200px; top:189px; }   
        </style>
        
        <!-- js scrolling -->
        <div id="tweets">
           <!-- Tweets will get loaded from jQuery -->
        </div>
        <div id="viewmore" style="background-color:gray; width:84%;pointer:cursor">
            <div style="text-align: center;padding-top: 10px;padding-bottom: 10px;pointer:cursor" onclick="return OnViewMore('<?php echo $loggedUserObj->userId; ?>','<?php echo $loggedUserObj->privacyType["Default_Setting"]; ?>',false,postTypeToRead.techno,localpageparentid);">
                View More >>
            </div>
           <!-- Tweets will get loaded from jQuery -->
        </div>
        <!--<div id="overlay">
           <img src="images/ajax-loader.gif" />
        </div>-->
        <!-- js scrolling -->
        
        <script type="text/javascript">            
            requserid='<?php echo $loggedUserObj->userId; ?>';
            requserprivacysetting='<?php echo $loggedUserObj->privacyType["Default_Setting"]; ?>';
            var loadTweets = function(lsttweet) {
               //getNewsFeeds('<?php  echo $loggedUserObj->userId; ?>','0','<?php echo $loggedUserObj->privacyType["Default_Setting"]; ?>');
               OnViewMore('<?php echo $loggedUserObj->userId; ?>','<?php echo $loggedUserObj->privacyType["Default_Setting"]; ?>',true,postTypeToRead.techno,'<?php echo $currentPostCategory; ?>');
            };            
            // First time, directly load the tweets
            loadTweets(0);
             
        </script>
		
		
		
		</div> 
		<div class="very_right" style="width:130px; min-height:200px; float:right;">
			<table width="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
				<td align="center">
					<?php 
                    if(count($sponcerinfo)>0)
                    {
                    ?>
                    <ul style="color:#7b7f81; font-weight:bold; margin-top:20px; list-style:none; text-shadow:none;">
					Sponsor
                    <?php
                    for($i=0;$i<count($sponcerinfo);$i++)
                    {
                    ?>
						<li style="text-align:center; box-shadow:none !important; padding:0; margin:0;"><div class="abcdef"><a href="<?php if($sponcerinfo[$i]['link']!="" && strstr($sponcerinfo[$i]['link'],"http://")){ echo $sponcerinfo[$i]['link']; }  ?>" target="_blank"><?php if($sponcerinfo[$i]['image_url']!="" && file_exists("uploads/sponcers/thumbs/".$sponcerinfo[$i]['image_url'])){ ?><img src="uploads/sponcers/thumbs/<?php echo $sponcerinfo[$i]['image_url']; ?>" title="<?php echo $sponcerinfo[$i]['sponcer_name']; ?>" width="79px" height="81px" /> <?php } ?></a></div><a href="<?php if($sponcerinfo[$i]['link']!="" && strstr($sponcerinfo[$i]['link'],"http://")){ echo $sponcerinfo[$i]['link']; }  ?>" target="_blank"><?php echo $sponcerinfo[$i]['sponcer_name']; ?></a></li>
                    <?php
                    }
                    ?>    
					</ul>
                    <?php
                    }
                    ?>
				</td>
			</tr>
			</table>
		</div>
	   
	      
</div>

    </div>
    
    <div class="clearfix"></div>
    <!--=================Body Contain end=======================-->
	 </div>
    <div class="clearfix"></div>
    
    <div id="popup"><span class="button b-close">X</span> 
    
        <form id="frmtechnoupdt" name="frmtechnoupdt" action="<?php  echo $_SERVER["PHP_SELF"]; ?>" method="post" target="_self" enctype="multipart/form-data">
            <input type="hidden" id="prvset" name="prvset" value="<?php echo $loggedUserObj->privacyType["Default_Setting"]; ?>" />
            <input type="hidden" id="action" name="action" value="tc_post" />
            <input type="hidden" id="nPostType" name="nPostType" value="7" />
    
            <div id="main_wrapper">
             	  <div class="new_inb3">
                  <div class="help-title" style="font-weight:bold; font-size:28px; text-shadow:1px 2px 3px #999;">Upload Form</div>
                  <?php
                if(isset($errormsg) && $errormsg!="")
                {
                    ?>
                    <div class="errormsg" ><?php echo $errormsg; ?><br /><br /></div>
                    <?php
                }
                
                
                //$technocats=$pdodbobj->fetch_array($pdodbobj->query("select id,cat_name from af_technocategories ",array()));
                
                ?>
                      <table border="0" cellpadding="10px" cellspacing="20" width="100%" align="left">
        				<tr>
        				  <td width="31%"><div class="help-title2">Techno Category<span style="color: red;">*</span></div></td>
        				  <td width="69%">
                            <select id="Post[Parent_ID]" name="Post[Parent_ID]" class="upload_frm" style="color:#90cae6" >
                                <option value="">Select Category</option>
                                <?php
                                for($i=0;$i<count($technocats);$i++)
                                {
                                    ?>
                                    <option value="<?php echo $technocats[$i]['id']; ?>" <?php if(isset($techno_cat) && $techno_cat==$technocats[$i]['id']){ echo "selected"; } ?> ><?php echo $technocats[$i]['cat_name']; ?></option>
                                    <?php
                                }
                                ?>
                            </select>
                          </td>
        				</tr>
        				<tr>
        					<td><div class="help-title2">Upload Image</div></td>
        					<td>
                            <!--
                            <input type="button" id="uploadme" value="Upload Image" />
                            <span id="status">No Result Yet</span>
                            -->
                            <input type="hidden" id="uploadedimagedata" name="uploadedimagedata" value="none" /> 
        					<input type="file" id="imgdata" name="imgdata"  />
        					
        				</tr>
        				<tr>
        					<td>
                                <div class="help-title2">Post Title<span style="color: red;">*</span></div>
                            </td>
        					<td>
                                <input type="text" id="Post[post_title]" name="Post[post_title]" class="upload_frm" placeholder="Post Title" value="<?php if(isset($post_title) && trim($post_title)!=""){ echo $post_title; } ?>" style="color:#90cae6" /><br />
                                
                            </td>
        				</tr>
                        <tr>
        					<td>
                                <div class="help-title2">Post Contents<span style="color: red;">*</span></div>
                            </td>
        					<td>
                                <textarea id="Post[post_content]" name="Post[post_content]" class="upload_frm" placeholder="Post Content" style="color:#90cae6" ><?php if(isset($post_content) && trim($post_content)!=""){ echo $post_content; } ?></textarea><br />
                                
                            </td>
        				</tr>
        				<tr>
        					<td>&nbsp;</td>
        					<td>
                                <input type="button" class="up_btn" value="Submit" onclick="return submitPost();"/> 
                                <input type="button" class="up_btn" value="Reset" onclick="return resetAllFields();" />
                                <input type="button" class="up_btn b-close" value="Cancel"  />
                            </td>
        				</tr>
        			</table>
                  </div>        
            </div>
        </form>
    </div>
    
    <div class="loader"></div>
   	<div id="backgroundPopup"></div>
    <input type="hidden" name="action" id="action" />
     
<style>
 #popup{
	background-color: #fff;
	border-radius:0px;
  	display: none;
	min-width: 450px;
	padding:10px;
 }
#popup {
	min-height: 250px
}
 .lt-ie9 .bModal {
	background-color: #000
}
 
.button.b-close, .button.bClose {
 	box-shadow: none;
	font: bold 131% sans-serif;
	padding: 0 6px 2px;
	position: absolute;
	right:5px;
	top:5px;
	cursor:pointer;
}
 </style>
<script src="js/jquery.bpopup.js"></script> 
<script src="js/scripting.min.js"></script> 
<script src="js/jquery.easing.1.3.js"></script> 

    

    <?php include_once "common_divs_include.php"; ?>

    <?php include_once "includes/footer.php"; ?>
<script lang="javascript">
//<![CDATA[

var rateclickid=0;
var universeappflag=1;

function submitPost(){
    if(validateTechnoUpdate()){
    // Get some values from elements on the page:
    $("#frmtechnoupdt").attr("method","post");
    $("#frmtechnoupdt").submit();
    //ust("frmtechnoupdt"); 
  }
}
function validateTechnoUpdate(){
    if(trim(document.getElementById('Post[Parent_ID]').value)=="")
    {
        alertify.alert("Please select technopost category.");
        return false;
    }
    else if(trim(document.getElementById('Post[post_title]').value)=="")
    {
        alertify.alert("Please enter the post title.");
        return false;
    }
    else if(trim(document.getElementById('Post[post_content]').value)=="")
    {
        alertify.alert("Please enter post contents.");
        return false;
    }
    else
    {
        return true;
    }
}
/*
$("#frmtechnoupdt").submit(function( event ) {
  // Stop form from submitting normally
  event.preventDefault();
  if(validateTechnoUpdate()){
    // Get some values from elements on the page:
    $("#frmtechnoupdt").submit();
    //ust("frmtechnoupdt"); 
  }
  
});
*/


function resetAllFields()
{
    if(trim(document.getElementById('Post[Parent_ID]').value)!="")
    {
        document.getElementById('Post[Parent_ID]').value="";
    }
    else if(trim(document.getElementById('Post[post_title]').value)!="")
    {
        document.getElementById('Post[post_title]').value="";
    }
    else if(trim(document.getElementById('Post[post_content]').value)!="")
    {
        document.getElementById('Post[post_content]').value="";
    }
    else if(trim(document.getElementById('imgdata').value)!="")
    {
        document.getElementById('imgdata').value="";
    }
}

function changerating(id,value,type)
{
    var readonlyflag=false;
    if(document.getElementById('loggedinuserid').value=="0")
    {
        readonlyflag=false;
    }
    
    for(var i=1;i<parseInt(document.getElementById(type+'count').value);i++)
    {
        if(document.getElementById('star_'+type+'_'+i))
        {
            document.getElementById('star_'+type+'_'+i).innerHTML="";
        }
    }
    
    for(var i=1;i<parseInt(document.getElementById(type+'count').value);i++)
    {
        if(document.getElementById('star_'+type+'_'+i))
        {
            if(id==i)
            {
                $("#star_"+type+'_'+i).raty({
                  score: value,  
                  click: function(score,evt) {
                    document.getElementById('gamesscore').value=score;
                    var starid=this.id;
                    typeidarr=starid.split("_");
                    starid=starid.replace("star","");
                    
                    document.getElementById('gameid').value=document.getElementById('entertainid'+starid).value;
                    rateclickid=typeidarr[2];
                    saveRating(typeidarr[1]);
                  }
                });
            }
            else
            {
                avgrating=parseInt(document.getElementById('avgrating_'+type+'_'+i).value);
                $("#star_"+type+'_'+i).raty({
                  score: avgrating,
                  readOnly: readonlyflag,  
                  click: function(score,evt) {
                    document.getElementById('gamesscore').value=score;
                    var starid=this.id;
                    typeidarr=starid.split("_");
                    starid=starid.replace("star","");
                    
                    document.getElementById('gameid').value=document.getElementById('entertainid'+starid).value;
                    rateclickid=typeidarr[2];
                    saveRating(typeidarr[1]);
                  }
                });
            }
        }
    }
}

function getmoreapps(type)
{
    if(universeappflag==1)
    {
        nextcount=1;
        disableLink('appmorelink'+type);
        
        $.ajax({
          cache:false,  
          async:false,
    	  url: "ajax_search/ajax_manageentapps.php?action=getapps&userid="+trim(document.getElementById('loggedinuserid').value)+"&currentcount="+trim(document.getElementById(type+'count').value)+"&nextcount="+nextcount+"&istrend="+trim(document.getElementById('istrend').value)+"&type="+type,
    	  success: function( data ) {
    	    
            var dataarr=data.split("~:~");
            if(trim(data)!="")
            {
                document.getElementById(type+'table').innerHTML=document.getElementById(type+'table').innerHTML+trim(dataarr[0]);
                document.getElementById(type+'count').value=dataarr[1];
            }
            else
            {
                alertify.alert("There is no more record found...");
                return false;
            }
            changerating(0,0,type);
    	  }
    	});
    }
    
}

function saveRating(type)
{
    if(document.getElementById('loggedinuserid').value=="0")
    {
        changerating(rateclickid,parseInt(document.getElementById('avgrating_'+type+'_'+rateclickid).value),type);
        alertify.alert('Please login first to rate the entertainment link.');
        return false;
    }
    else
    {
        $.ajax({
          cache:false,  
    	  url: "ajax_search/ajax_manageentapps.php?action=saverating&userid="+trim(document.getElementById('loggedinuserid').value)+"&appid="+trim(document.getElementById('gameid').value)+"&starrating="+parseInt(trim(document.getElementById('gamesscore').value)),
    	  success: function( data ) {
    	    if(data=="Already")
            {
                changerating(rateclickid,parseInt(document.getElementById('avgrating_'+type+'_'+rateclickid).value),type);
                alertify.alert('You have already rated this entertainment link.');
                return false;
            }
            else if(parseInt(data)>=0)
            {
                alertify.alert("You have successfully rated this entertainment link.");
                document.getElementById('avgrating_'+type+'_'+rateclickid).value=trim(parseInt(data).toString());
                changerating(rateclickid,parseInt(data),type);
                return false;
            }
            else
            {
                alertify.alert("There is an error in updating entertainment link rating.");
                return false;
            }
    	  }
    	});
        
    }
}

function updatePickcounter(appid,userid,linkval,starcountid,type)
{
    if(userid==0)
    {
        alertify.alert('Please login first to pick the entertainment link.');
        return false;
    }
    else
    {
        $.ajax({
          cache:false,  
    	  url: "ajax_search/ajax_manageentapps.php?action=pickupdate&userid="+trim(document.getElementById('loggedinuserid').value)+"&appid="+appid,
    	  success: function( data ) {
    	    if(parseInt(data)>=0)
            {
                document.getElementById('pick_'+type+'_'+starcountid).innerHTML=trim(parseInt(data).toString());
                window.open(linkval);
                return false;
            }
            else
            {
                alertify.alert("There is an error in picking the entertainment link.");
                return false;
            }
    	  }
    	});
    }
}


<?php
if(isset($msg_success) && $msg_success!="")
{
    ?>
    alertify.alert("<?php echo $msg_success; ?>");
    <?php
}

if(isset($msg_error) && $msg_error!="")
{
    ?>
    alertify.alert("<?php echo $msg_error; ?>");
    <?php
}
?>


//]]>
</script>


<script type="text/javascript" src="js/ajaxupload.3.5.js" ></script>

<script type="text/javascript" >
$(document).ready(function(){
    $.noConflict();
    var status = $('#status');
    new AjaxUpload('uploadme', {
    action: "UploadFile.php",
    name: 'userfile',
    onSubmit: function(file, extension) {
      status.html('Uploading...');
    },
    onComplete: function(file, response) {
      //thumb.load(function(){
//        $('div.preview').removeClass('loading');
//        thumb.unbind();
//      });
//      thumb.attr('src', response);
        document.getElementById('uploadedimagedata').value =response;
        var jsonval=$.parseJSON(response);
        var fpath=jsonval.tmp_name.replace(new RegExp("/", 'g'),'\\');
        
        status.html("Done");
    }
  });  
});
	
</script>